<?php
require './vendor/autoload.php';
$config = array(
    "mongo_hosts" => 'mongodb://192.168.112.17:27017',
    "mongo_database" => "fkl",
    "mongo_tables" => "win_cdr",
);
$client = new MongoDB\Client($config['mongo_hosts']);
$mongoClient = $client->selectDatabase($config['mongo_database']);

$csvFile = fopen("1.csv",'r');
while ($csvData = fgetcsv($csvFile)) { //每次读取CSV里面的一行内容
    if (!is_numeric($csvData[1])) {
        continue;
    }
    $params = array(
        '_id'=>(int) $csvData[0],
        'vcc_id'=>1,
        'call_id'=>$csvData[0],
        'caller' =>(string) $csvData[1],
        "start_time" => strtotime($csvData[5])
    );
    $col = $mongoClient->selectCollection($config['mongo_tables']);
    $response = $col->insertOne($params);
}
exit;
?>